package com.suanfa.scanner;

import java.util.Random;
import java.util.Scanner;

/**
 * @author jukg
 * @date 2025/03/01 12:13
 * @description 掷骰子游戏
 */
public class Shaizi {

    public static void main(String[] args) {
        /*************掷色子游戏开始************/
        Scanner in = new Scanner(System.in);
        Random random = new Random();
        int total = 0;
        while (true){
            System.out.println("/*************回车掷骰子，空格退出************/");
            String input = in.nextLine();
            if(input.isEmpty()){
                int num = random.nextInt(5) + 1;
                System.out.println("当前掷到:" + num);
                if(num == 1){
                    System.out.println("当前掷到1，得分清零，游戏结束");
                    break;
                }else {
                    total += num;
                }
                System.out.println("当前得分:" + total);
            }else {
                System.out.println("当前得分:" + total);
                break;
            }

        }
    }
}
